#include "uhm/common.hxx"
#include "uhm/util.hxx"

#include "uhm/discrete/base/mesh.hxx"

#define N 1

using namespace uhm;

typedef ID_Node_<N>             Id_Nd;
typedef ID_Element_<N>          Id_El;
typedef Int_                    Uhm;

typedef Mesh_<Id_Nd,Id_El,Uhm> Mesh;

int main (int argc, char **argv) {

  Mesh::_Id_El_ el;
  Mesh::_Id_Nd_ nd;

  Mesh mesh;

  Mesh::Node_*    n;
  Mesh::Element_* e;

  el.set_id(0, 10); e = mesh.add_element(el); 
  e->push_begin();
  nd.set_id(0, 0); n = mesh.add_node(nd); e->push(n);
  nd.set_id(0, 1); n = mesh.add_node(nd); e->push(n);
  nd.set_id(0, 2); n = mesh.add_node(nd); e->push(n);
  e->push_end();
  
  el.set_id(0, 20); e = mesh.add_element(el);
  e->push_begin();
  nd.set_id(0, 2); n = mesh.add_node(nd); e->push(n);
  nd.set_id(0, 3); n = mesh.add_node(nd); e->push(n);
  nd.set_id(0, 4); n = mesh.add_node(nd); e->push(n);
  e->push_end();

  el.set_id(0, 30); e = mesh.add_element(el);
  e->push_begin();
  nd.set_id(0, 3); n = mesh.add_node(nd); e->push(n);
  nd.set_id(0, 4); n = mesh.add_node(nd); e->push(n);
  nd.set_id(0, 5); n = mesh.add_node(nd); e->push(n);
  e->push_end();

  e = mesh.add_element();

  std::cout << "** 3 elements and 1 element that mesh added\n";
  std::cout << mesh << std::endl;

  el.set_id(0,0);
  mesh.clear(el);

  std::cout << "** mesh is cleared\n";
  std::cout << mesh << std::endl;  
  return true;
}


